part of 'component.dart';

class UITextField extends StatelessWidget {
  const UITextField(
      {Key? key,
      this.name,
      this.suffixIcon,
      required this.hintText,
      this.controller,
      this.obscureText,
      this.maxLength,
      this.height,
      this.prefixWidth,
      this.backgroundColor,
      this.keyboardType,
      this.inputFormatters,
      this.borderRadius})
      : super(key: key);
  final String? name;
  final Widget? suffixIcon;
  final String hintText;
  final bool? obscureText;
  final int? maxLength;
  final double? height;
  final TextInputType? keyboardType;
  final TextEditingController? controller;
  final double? prefixWidth;
  final Color? backgroundColor;
  final BorderRadius? borderRadius;
  final List<TextInputFormatter>? inputFormatters;
  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: borderRadius ?? BorderRadius.circular(circle4),
      child: Container(
        height: height ?? 50.r,
        alignment: Alignment.center,
        padding: EdgeInsets.symmetric(horizontal: gap10),
        decoration: BoxDecoration(
            color: backgroundColor,
            border: const Border(
                bottom: BorderSide(color: ColorsUtil.separator, width: 1))),
        child: TextField(
          controller: controller,
          maxLength: maxLength,
          obscureText: obscureText ?? false,
          keyboardType: keyboardType,
          textAlignVertical: TextAlignVertical.center,
          inputFormatters: inputFormatters,
          decoration: InputDecoration(
            isCollapsed: true,
            counterText: '',
            prefixIcon: name == null
                ? null
                : Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      SizedBox(
                        width: prefixWidth,
                        child: Text(
                          name!,
                          style: pfMediumStyle(
                              color: ColorsUtil.title, fontSize: font15),
                        ),
                      )
                    ],
                  ),
            suffixIcon: suffixIcon,
            hintText: hintText,
            hintStyle:
                pfMediumStyle(color: ColorsUtil.placeholder, fontSize: font15),
            enabledBorder: InputBorder.none,
            disabledBorder: InputBorder.none,
            focusedBorder: InputBorder.none,
          ),
        ),
      ),
    );
  }
}
